package com.tencent.smtt.sdk.a;

import MTT.ThirdAppInfoNew;
import android.content.Context;
import com.tencent.smtt.sdk.QbSdk;
import com.tencent.smtt.sdk.TbsConfig;
import com.tencent.smtt.sdk.TbsCoreLoadStat;
import com.tencent.smtt.sdk.TbsDownloadConfig;
import com.tencent.smtt.sdk.TbsDownloader;
import com.tencent.smtt.sdk.TbsShareManager;
import com.tencent.smtt.utils.TbsLog;
import com.tencent.smtt.utils.o;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import kotlin.UByte;
import org.json.JSONObject;

/* loaded from: classes2.dex */
public class b {
    public static byte[] a;

    static {
        try {
            a = "65dRa93L".getBytes("utf-8");
        } catch (UnsupportedEncodingException unused) {
        }
    }

    private static String a(Context context) {
        try {
            byte[] byteArray = context.getPackageManager().getPackageInfo(context.getPackageName(), 64).signatures[0].toByteArray();
            if (byteArray != null) {
                MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
                messageDigest.update(byteArray);
                byte[] digest = messageDigest.digest();
                if (digest != null) {
                    StringBuilder sb = new StringBuilder("");
                    if (digest != null && digest.length > 0) {
                        for (int i = 0; i < digest.length; i++) {
                            String upperCase = Integer.toHexString(digest[i] & UByte.MAX_VALUE).toUpperCase();
                            if (i > 0) {
                                sb.append(":");
                            }
                            if (upperCase.length() < 2) {
                                sb.append(0);
                            }
                            sb.append(upperCase);
                        }
                        return sb.toString();
                    }
                    return null;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void a(ThirdAppInfoNew thirdAppInfoNew, Context context) {
        new c("HttpUtils", context, thirdAppInfoNew).start();
    }

    /* JADX WARN: Removed duplicated region for block: B:26:0x00ab A[Catch: all -> 0x0126, TryCatch #2 {all -> 0x0126, blocks: (B:24:0x0075, B:26:0x00ab, B:28:0x00b4, B:30:0x00c8, B:32:0x00ce, B:34:0x00d2, B:36:0x00d8, B:37:0x00da, B:39:0x00e0, B:41:0x00e4, B:43:0x00ea, B:44:0x00ec, B:47:0x00f8, B:49:0x00fe, B:54:0x010c, B:56:0x0116, B:57:0x011e, B:50:0x0102, B:51:0x0105, B:27:0x00ae), top: B:66:0x0075 }] */
    /* JADX WARN: Removed duplicated region for block: B:27:0x00ae A[Catch: all -> 0x0126, TryCatch #2 {all -> 0x0126, blocks: (B:24:0x0075, B:26:0x00ab, B:28:0x00b4, B:30:0x00c8, B:32:0x00ce, B:34:0x00d2, B:36:0x00d8, B:37:0x00da, B:39:0x00e0, B:41:0x00e4, B:43:0x00ea, B:44:0x00ec, B:47:0x00f8, B:49:0x00fe, B:54:0x010c, B:56:0x0116, B:57:0x011e, B:50:0x0102, B:51:0x0105, B:27:0x00ae), top: B:66:0x0075 }] */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00e0 A[Catch: all -> 0x0126, TryCatch #2 {all -> 0x0126, blocks: (B:24:0x0075, B:26:0x00ab, B:28:0x00b4, B:30:0x00c8, B:32:0x00ce, B:34:0x00d2, B:36:0x00d8, B:37:0x00da, B:39:0x00e0, B:41:0x00e4, B:43:0x00ea, B:44:0x00ec, B:47:0x00f8, B:49:0x00fe, B:54:0x010c, B:56:0x0116, B:57:0x011e, B:50:0x0102, B:51:0x0105, B:27:0x00ae), top: B:66:0x0075 }] */
    /* JADX WARN: Removed duplicated region for block: B:46:0x00f6  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x0108  */
    /* JADX WARN: Removed duplicated region for block: B:56:0x0116 A[Catch: all -> 0x0126, TryCatch #2 {all -> 0x0126, blocks: (B:24:0x0075, B:26:0x00ab, B:28:0x00b4, B:30:0x00c8, B:32:0x00ce, B:34:0x00d2, B:36:0x00d8, B:37:0x00da, B:39:0x00e0, B:41:0x00e4, B:43:0x00ea, B:44:0x00ec, B:47:0x00f8, B:49:0x00fe, B:54:0x010c, B:56:0x0116, B:57:0x011e, B:50:0x0102, B:51:0x0105, B:27:0x00ae), top: B:66:0x0075 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public static void a(android.content.Context r6, java.lang.String r7, java.lang.String r8, java.lang.String r9, int r10, boolean r11, long r12) {
        /*
            Method dump skipped, instructions count: 299
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.smtt.sdk.a.b.a(android.content.Context, java.lang.String, java.lang.String, java.lang.String, int, boolean, long):void");
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static JSONObject c(ThirdAppInfoNew thirdAppInfoNew, Context context) {
        int i;
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("APPNAME", thirdAppInfoNew.sAppName);
            jSONObject.put("TIME", thirdAppInfoNew.sTime);
            jSONObject.put("QUA2", thirdAppInfoNew.sQua2);
            jSONObject.put("LC", thirdAppInfoNew.sLc);
            jSONObject.put("GUID", thirdAppInfoNew.sGuid);
            jSONObject.put("IMEI", thirdAppInfoNew.sImei);
            jSONObject.put("IMSI", thirdAppInfoNew.sImsi);
            jSONObject.put("MAC", thirdAppInfoNew.sMac);
            jSONObject.put("PV", thirdAppInfoNew.iPv);
            jSONObject.put("CORETYPE", thirdAppInfoNew.iCoreType);
            jSONObject.put("APPVN", thirdAppInfoNew.sAppVersionName);
            jSONObject.put("SIGNATURE", thirdAppInfoNew.sAppSignature == null ? "0" : thirdAppInfoNew.sAppSignature);
            jSONObject.put("PROTOCOL_VERSION", 3);
            jSONObject.put("ANDROID_ID", thirdAppInfoNew.sAndroidID);
            if (TbsShareManager.isThirdPartyApp(context)) {
                jSONObject.put("HOST_COREVERSION", TbsShareManager.getHostCoreVersions(context));
            } else {
                jSONObject.put("HOST_COREVERSION", TbsDownloader.getCoreShareDecoupleCoreVersionByContext(context));
                jSONObject.put("DECOUPLE_COREVERSION", TbsDownloader.getCoreShareDecoupleCoreVersionByContext(context));
            }
            if (thirdAppInfoNew.iCoreType == 0) {
                jSONObject.put("WIFICONNECTEDTIME", thirdAppInfoNew.sWifiConnectedTime);
                jSONObject.put("CORE_EXIST", thirdAppInfoNew.localCoreVersion);
                int i2 = TbsCoreLoadStat.mLoadErrorCode;
                if (thirdAppInfoNew.localCoreVersion <= 0) {
                    jSONObject.put("TBS_ERROR_CODE", TbsDownloadConfig.getInstance(context).getDownloadInterruptCode());
                } else {
                    jSONObject.put("TBS_ERROR_CODE", i2);
                }
                if (i2 == -1) {
                    TbsLog.e("sdkreport", "ATTENTION: Load errorCode missed!");
                }
            }
            TbsDownloadConfig.getInstance(context).uploadDownloadInterruptCodeIfNeeded(context);
            try {
                if (QbSdk.getTID() != null) {
                    if (thirdAppInfoNew.sAppName.equals(TbsConfig.APP_QQ)) {
                        jSONObject.put("TID", o.a().a(QbSdk.getTID()));
                        i = 1;
                    } else if (thirdAppInfoNew.sAppName.equals(TbsConfig.APP_WX)) {
                        jSONObject.put("TID", QbSdk.getTID());
                        i = 0;
                    }
                    jSONObject.put("TIDTYPE", i);
                }
            } catch (Exception unused) {
            }
            return jSONObject;
        } catch (Exception unused2) {
            TbsLog.e("sdkreport", "getPostData exception!");
            return null;
        }
    }
}
